<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=D6WOzHaymzVVKvgiy8UbhQEznkgeK6BD"></script>
    <!-- RAVVBy2YxgEk2CNdV1ays5XLXv2EOQHo -->
    <title>Document</title>
    <!-- 31.24916171 -->
    <!--121.48789949 -->
    <!-- 31.2533023102,121.5710605484 -->
</head>

<body>
    <img src="http://api.map.baidu.com/staticimage/v2?ak=RAVVBy2YxgEk2CNdV1ays5XLXv2EOQHo&mcode=&center=121.48789949,31.24916171&width=300&height=200&zoom=11">
    </img>
    <script>















    </script>
    <script>

        function getAddress(longitude, latitude) {
            // var latitude= 31.24916171
            // var longitude= 121.48789949 
            // 31.2533023102,121.5710605484
            var latitude = 31.2533023102
            var longitude =121.5710605484


            var address;

            //通过baiduMap API获取街道名称
            var map = new BMap.Map("allmap");
            var point = new BMap.Point(longitude, latitude);
            var gc = new BMap.Geocoder();

            gc.getLocation(point, function (rs) {
                console.log('res', rs)
                var addComp = rs.addressComponents;
                address = addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber;
            });
            console.log('address', address)
            return address;

        }
        getAddress()

    </script>
</body>

</html>